function camelize(str) {
    let strArr = str.split('-');
    let newArr = [];
    for (let i = 0; i < strArr.length; i++) {
        if (i == 0) {
            newArr.push(strArr[i]);
        } else {
            let curStr = strArr[i].slice(0, 1).toUpperCase() + strArr[i].slice(1);
            newArr.push(curStr);
        }
    }        
    return newArr.join('');
}

alert(camelize("background-color"));
alert(camelize("list-style-image"));
alert(camelize("-webkit-transition"));


// 官方答案，太牛逼了
function camelize2(str) {
    return str
    .split('-')
    .map(
        (word, index) => index == 0 ? word : word[0].toUpperCase() + word.slice(1)
     )
    .join('');
}